package com.lqw.vhr.service;

import com.lqw.vhr.mapper.EmployeetrainMapper;
import com.lqw.vhr.model.EmployeeEc;
import com.lqw.vhr.model.Employeetrain;
import com.lqw.vhr.model.RespPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployTrainService {

    @Autowired
    EmployeetrainMapper employeetrainMapper;

    public RespPageBean getEmpTrainByPage(Integer page, Integer size, String keyword) {
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        List<Employeetrain> employeetrains = employeetrainMapper.getEmpTrainByPage(page, size, keyword);
        long total = employeetrainMapper.countEmpTrainByPage(page, size, keyword);
        RespPageBean respPageBean = new RespPageBean();
        respPageBean.setData(employeetrains);
        respPageBean.setTotal(total);
        return respPageBean;
    }

    public int updateEmpTrain(Employeetrain employeetrain) {
        return employeetrainMapper.updateByPrimaryKeySelective(employeetrain);
    }

    public int addEmpTrain(Employeetrain employeetrain) {
        return employeetrainMapper.insertSelective(employeetrain);
    }

    public int deleteEmpTrainById(Integer id) {
        return employeetrainMapper.deleteByPrimaryKey(id);
    }


}
